home *** CD-ROM | disk | FTP | other *** search
/ CD/PC Actual 76 / DVD Actual 1 Marzo 2003.iso / Trial / TurboCAD 7.1 Pro / Data.Cab / F29896_PalDlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-11-10  |  2.1 KB  |  96 lines

  1. // PalDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "CustomPalette.h"
  6. #include "PalDlg.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CPalDlg dialog
  16.  
  17.  
  18. CPalDlg::CPalDlg(CWnd* pParent /*=NULL*/)
  19.     : CDialog(CPalDlg::IDD, pParent)
  20. {
  21.     //{{AFX_DATA_INIT(CPalDlg)
  22.         // NOTE: the ClassWizard will add member initialization here
  23.     //}}AFX_DATA_INIT
  24. }
  25.  
  26. IMPLEMENT_DYNAMIC(CPalDlg, CDialog)
  27.  
  28. void CPalDlg::DoDataExchange(CDataExchange* pDX)
  29. {
  30.     CDialog::DoDataExchange(pDX);
  31.     //{{AFX_DATA_MAP(CPalDlg)
  32.         // NOTE: the ClassWizard will add DDX and DDV calls here
  33.     //}}AFX_DATA_MAP
  34. }
  35.  
  36.  
  37. BEGIN_MESSAGE_MAP(CPalDlg, CDialog)
  38.     //{{AFX_MSG_MAP(CPalDlg)
  39.     ON_BN_CLICKED(IDC_TEST, OnTest)
  40.     //}}AFX_MSG_MAP
  41. END_MESSAGE_MAP()
  42.  
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CPalDlg message handlers
  45.  
  46. IApplication* GetTcApp()
  47. {
  48.  IApplication *pIApplication = NULL;
  49.  
  50.  BOOL bCreateInstance = TRUE;
  51.  IUnknown* pUnk = NULL;
  52.  HRESULT hRes = ::GetActiveObject(CLSID_Application, NULL, &pUnk);
  53.  if (pUnk == NULL)
  54.   return NULL;
  55.  
  56.  hRes = pUnk->QueryInterface(IID_IApplication, (void**)&pIApplication);
  57.  pUnk->Release();
  58.  if (FAILED(hRes))
  59.  {
  60.   return NULL;
  61.  }
  62.  
  63.  return pIApplication;
  64. }
  65.  
  66. void CPalDlg::OnTest() 
  67. {
  68.     // TODO: Add your control notification handler code here
  69.     HRESULT hRes = E_FAIL;
  70.     Drawings* pDrs = NULL;
  71.     long lDrawingsCount = 0;
  72.     CString strTmp;
  73.     strTmp = "There are  drawings loaded";
  74.  
  75.     IApplication* pIApp = GetTcApp();
  76.     if(pIApp !=NULL)
  77.     {
  78.         hRes = pIApp->get_Drawings(&pDrs);
  79.         if(SUCCEEDED(hRes))
  80.         {
  81.             hRes = pDrs->get_Count(&lDrawingsCount);
  82.         
  83.         }
  84.     }
  85.     char v[10];
  86.     memset(v, 0, 10);
  87. //    lPsscount++;
  88.     _ltoa(lDrawingsCount,v, 10);
  89.     strTmp.Insert (10,v);
  90.     //strTmp.Format("There are %l drawings loaded ",lDrawingsCount);
  91. //    AfxMessageBox(strTmp); 
  92.     MessageBox(strTmp, "Custom docking palette");
  93.     RELEASE(pDrs);
  94.     RELEASE(pIApp);
  95. }
  96.